<template>
    <div>
        <div class="t_showview">
          <section class="resume-review">
            <el-form ref="form" label-width="150px" label-position="left">
               <!-- 个人信息 -->
              <section class="block pt30">
                <div class="title">
                  个人信息
                  <!-- <div class="edit-btn" type="text" @click="linkTo('userInfo')">
                     修改
                  </div> -->
                </div>
                <div class="user-info">
                  <img
                    class="touxiang"
                    v-if="userInfo.studentPictureUrl"
                    :src="userInfo.studentPictureUrl"
                    alt="用户头像"
                  />
                  <img
                    class="touxiang"
                    v-else
                    src="../../assets/images/touxiang1.png"
                    alt="用户头像"
                  />
                  <div class="row1">{{ userInfo.nickname }}</div>
                  <div class="row2">
                    {{ userInfo.sex }}<span class="line"></span>{{ userInfo.age
                    }}<span class="line"></span>{{ userInfo.liveCity
}}<span class="line"></span>{{ userInfo.clan
}}<span class="line"></span>{{ userInfo.political }}
                  </div>
                </div>
              </section>
              <!-- 联系方式 -->
              <section class="block pt30">
                <div class="title">
                  联系方式
                </div>
                <div class="contact">
                  <div>
                    <div>
                      <div class="row1">
                        <span>手机号码</span>
                        <span>{{ userInfo.mobile }}</span>
                      </div>
                    </div>
                    <div >
                      <div class="row1">
                        <span>邮箱地址</span>
                        <span>{{ userInfo.email }}</span>
                      </div>
                    </div>
                  </div>
                </div>
              </section>
         
              <!-- 求职状态 -->
              <section class="block pt30">
                <div class="title">
                  求职状态 <span class="isRequire">*</span
                  >
                  <div
                    class="add-btn"
                    @click="openJobStatusEdit"
                    v-if="!jobStatusFlag"
                  >
                    编辑
                  </div>
                </div>
                <div class="job-wish-item" v-if="!jobStatusFlag">
                  <div class="row1" style="margin-bottom: 0">
                    {{
                        (userInfo.jobStatus || "--") +
                        "/" +
                        (userInfo.inJobTime || "--")
                    }}
                  </div>
                </div>
                <div class="" v-if="jobStatusFlag">
                  <el-form
                    ref="jobStatusRef"
                    :model="jobStatusFrom"
                    label-position="left"
                    label-width="150px"
                  >
                    <el-form-item label="当前状态" required>
                      <span slot="label" class="left-label">
                        <span calss="cn-label">当前状态</span><br />
                    
                      </span>
                      <SelectCom
                        :options="[
                            { label: '正在实习', value: '正在实习' },
                            { label: '暂无实习', value: '暂无实习' },
                        ]"
                        v-model="jobStatusFrom.jobStatus"
                      />
                    </el-form-item>
                    <el-form-item label="入职时间" required>
                      <span slot="label" class="left-label">
                        <span calss="cn-label">入职时间</span><br />
                    
                      </span>
                      <SelectCom
                        :options="[
                            { label: '随时入职', value: '随时入职' },
                            { label: '2周内入职', value: '2周内入职' },
                            { label: '时间待定', value: '时间待定' },
                        ]"
                        v-model="jobStatusFrom.inJobTime"
                      />
                    </el-form-item>
                    <el-form-item label=" ">
                      <el-button @click="editJobStatus">取消</el-button>
                      <el-button type="primary" @click="submitJobStatus"
                        >确定</el-button
                      >
                    </el-form-item>
                  </el-form>
                </div>
              </section>
              <!-- 模板名称 -->
              <section class="block pt30">
                <div class="title">
                  简历名称 <span class="isRequire">*</span
                  >
                </div>
                <el-input
                  v-model="name"
                  placeholder="请输入简历名称"
                  maxlength="20"
                  style="width: 180px"
                ></el-input>
              </section>
              <!-- 求职/实习意向 -->
        <section class="block pt30">
          <div class="title">
            求职/实习意向 <span class="isRequire">*</span
            >
            <div
          class="add-btn"
                @click="addItem('internshipDesire')"
                v-if="!internshipDesireFlag && internshipDesire.length > 0"
              >
                + 添加求职意向
              </div>
                </div>
                <div
                  class="empty-btn"
                  @click="addItem('internshipDesire')"
                  v-if="internshipDesire.length <= 0 && !internshipDesireFlag"
                >
                  <div class="t_add_box">
                    <div> <i class="add-icon"></i>添加求职意向 </div>
                  </div>
                </div>
                <div
                  class="job-wish-item"
                  v-for="(item, index) in internshipDesire"
                  :key="index"
                  v-if="!internshipDesireFlag"
                >
                  <div class="row1">{{ item.jobName }}</div>
                  <div class="row4">
                    <div class="row4_flex">
                      <span class="label">薪资要求：</span
                      ><span class="value"
                        >{{ item.lowestSalary }}-{{ item.highestSalary }}元</span
                      >
                    </div>
                    <div class="row4_flex">
                      <span class="label">期望城市：</span
                      ><span class="value">{{ item.targetCity }}</span>
                    </div>
                  </div>
                  <div class="row4">
                    <span class="label">期望行业：</span>
                    <span
                      class="value"
                      v-for="(it, i) in item.expectedIndustry"
                      :key="i"
                      v-if="it"
                      >{{ it }}
                    </span>
                  </div>
                  <div
                    class="edit-btn top0"
                    type="text"
                    @click="editItem('internshipDesire', item, index)"
                  >
                  <!-- editItem('internshipDesire', item, index) -->
                    <i class="edit-icon"></i>
                  </div>
                  <div
                      class="t_delete-btn top0"
                      type="text"
                      @click="deleteItem('internshipDesire', item, index, item.jobName)"
                    >
                      <i class="t_delete-icon"></i>
                    </div>
                  
                </div>
                <!-- <InternshipDesire
                  v-show="internshipDesireFlag"
                  ref="internshipDesire"
                /> -->
              </section>
              <!-- 教育经历 -->
              <section class="block pt30">
                <div class="title">
                  教育经历<span class="isRequire">*</span
                  >
                  <div
                    class="add-btn"
                    @click="addItem('educationalExperience')"
                    v-if="
                        !educationalExperienceFlag && educationalExperience.length > 0
                    "
                  >
                    + 添加教育经历
                  </div>
                </div>
                <div
                  class="empty-btn"
                  @click="addItem('educationalExperience')"
                  v-if="
                      educationalExperience.length <= 0 && !educationalExperienceFlag
                  "
                >
                  <div class="t_add_box">
                    <div> <i class="add-icon"></i>添加教育经历 </div>
                  </div>
                </div>
                <div class="word-record-item" v-if="!educationalExperienceFlag">
                  <div
                    class="educate t_educate"
                    v-for="(item, index) in educationalExperience"
                    :key="index"
                  >
                    <div class="row1">{{ item.schoolName }}</div>
                    <span class="info">{{ item.educationalBackground }}</span>
                    <span class="info">{{ item.major }}</span>
                    <span class="info">
                          {{ ["无", "有"][item.diploma] }}学位证书</span
                        >
                    <div>
                      
                      <span class="info">{{ item.intakeTime + "~" + item.graduateTime }}</span>
                      <span class="info" v-if="item.graduateTime == '至今'">{{ "在读 " + getEducationOptions(item.grade) }}</span>
                    </div>
                      <div>
                      <span class="info">{{ item.isOverseasStudy || "无" }}海外留学经历</span>

                      </div>
                    <div
                      class="edit-btn"
                      type="text"
                      @click="editItem('educationalExperience', item, index)">
                      <i class="edit-icon"></i>
                    </div>
                    <div
                      class="t_delete-btn"
                      type="text"
                      @click="deleteItem('educationalExperience', item, index, item.schoolName)">
                      <i class="t_delete-icon"></i>
                    </div>
                  </div>
                </div>
                <!-- <EducationalExperience
                  v-show="educationalExperienceFlag"
                  ref="educationalExperience"
                /> -->
              </section>
              <!-- 工作/实习经历 -->
              <section class="block pt30">
                <div class="title">
                  工作/实习经历
                  <div
                    class="add-btn"
                    @click="addItem('workExperience')"
                    v-if="!workExperienceFlag && workExperience.length > 0"
                  >
                    + 工作/实习经历
                  </div>
                </div>
                <div
                  class="empty-btn"
                  @click="addItem('workExperience')"
                  v-if="workExperience.length <= 0 && !workExperienceFlag"
                >
                 <div class="t_add_box">
                    <div> <i class="add-icon"></i>添加工作/实习经历 </div>
                  </div>
                </div>
                <div
                  class="job-wish-item"
                  v-for="(item, index) in workExperience"
                  :key="index"
                  v-if="!workExperienceFlag"
                >
                  <div class="row1">{{ item.companyName }}</div>
                  <div class="row4 t_row4">
                    <span class="value"
                      >{{ item.entryTime }}~{{ item.resignationTime }}</span
                    >
                  </div>
                  <div class="row4">
                    <span class="label">{{ item.jobName }}</span>
                    <span class="value">{{ ["实习", "全职"][item.jobType] }}</span>
                  </div>
                  <div
                    class="row4"
                    v-if="item.jobDescription"
                    v-html="item.jobDescription.replace(/\n/gm, '<br>')"
                  ></div>
                  <div
                    class="edit-btn top0"
                    type="text"
                    @click="editItem('workExperience', item, index)"
                  >
                    <i class="edit-icon"></i>
                  </div>
                   <div
                      class="t_delete-btn"
                      type="text"
                      @click="deleteItem('workExperience', item, index, item.companyName)">
                      <i class="t_delete-icon"></i>
                    </div>
                </div>
                <!-- <WorkExperience v-show="workExperienceFlag" ref="workExperience" /> -->
              </section>
              <!-- 项目经历 -->
              <section class="block pt30">
                <div class="title">
                  项目经历
                  <div
                    class="add-btn"
                    @click="addItem('projectExperience')"
                    v-if="!projectExperienceFlag && projectExperience.length > 0"
                  >
                    + 添加项目经历
                  </div>
                </div>
                <div
                  class="empty-btn"
                  @click="addItem('projectExperience')"
                  v-if="projectExperience.length <= 0 && !projectExperienceFlag"
                >
                  <div class="t_add_box">
                    <div> <i class="add-icon"></i>添加项目经历 </div>
                  </div>
                </div>
                <div
                  class="job-wish-item"
                  v-for="(item, index) in projectExperience"
                  :key="index"
                  v-if="!projectExperienceFlag"
                >
                  <div class="row1">{{ item.projectName }}</div>
                  <div class="row4">
                    <span class="value">{{ item.beginTime }}~{{ item.endTime }}</span>
                  </div>
                  <div
                    class="row4"
                    v-if="item.projectDescription"
                    v-html="item.projectDescription.replace(/\n/gm, '<br>')"
                  ></div>
                  <div
                    class="edit-btn top0"
                    type="text"
                    @click="editItem('projectExperience', item, index)"
                  >
                    <i class="edit-icon"></i>
                  </div>
                  <div
                    class="t_delete-btn"
                    type="text"
                    @click="deleteItem('projectExperience', item, index, item.projectName)">
                    <i class="t_delete-icon"></i>
                  </div>
                </div>
                <!-- <ProjectExperience
                  v-show="projectExperienceFlag"
                  ref="projectExperience"
                /> -->
              </section>
              <!-- 语言能力 -->
              <section class="block pt30">
                <div class="title">
                  语言能力
                  <div
                    class="add-btn"
                    @click="addItem('languageAbility')"
                    v-if="!languageAbilityFlag && languageAbility.length > 0"
                  >
                    + 添加语言能力
                  </div>
                </div>
                <div
                  class="empty-btn"
                  @click="addItem('languageAbility')"
                  v-if="languageAbility.length <= 0 && !languageAbilityFlag"
                >
                  <div class="t_add_box">
                    <div> <i class="add-icon"></i>添加语言能力 </div>
                  </div>
                </div>
                <div class="word-record-item" v-if="!languageAbilityFlag">
                  <div
                    class="educate"
                    v-for="(item, index) in languageAbility"
                    :key="index"
                  >
                  <!-- {{ item }} -->
                  <!-- <div> -->
                    {{ item.languageName }}<span class="info info_left">{{ item.level }}</span>
                    <!-- <div
                      class="edit-btn"
                      type="text"
                      @click="editItem('languageAbility', item, index)"
                    >
                      <i class="edit-icon"></i>
                    </div> -->
                    <div
                      class="edit-btn"
                      type="text"
                      @click="deleteItem('languageAbility', item, index, item.languageName)"
                    >
                      <i class="t_delete-icon"></i>
                    </div>
                  </div>
                </div>
              </section>
              <!-- 专业技能 -->
              <section class="block pt30">
                <div class="title">
                  专业技能
                  <div
                    class="add-btn"
                    @click="addItem('specialtyAbility')"
                    v-if="!specialtyAbilityFlag && specialtyAbility.length > 0"
                  >
                    + 添加专业技能
                  </div>
                </div>
                <div
                  class="empty-btn"
                  @click="addItem('specialtyAbility')"
                  v-if="specialtyAbility.length <= 0 && !specialtyAbilityFlag"
                >
                <div class="t_add_box">
                  <div> <i class="add-icon"></i>添加专业技能 </div>
                </div>
                </div>
                <div class="word-record-item" v-if="!specialtyAbilityFlag">
                  <div class="educate" v-for="(item, index) in specialtyAbility">
                    {{ item.specialtyName }}<span class="info info_left">{{ item.level }}</span>
                    <!-- <div
                      class="edit-btn"
                      type="text"
                      @click="editItem('specialtyAbility', item, index)"
                    >
                      <i class="edit-icon"></i>
                    </div> -->
                    <div
                      class="edit-btn"
                      type="text"
                      @click="deleteItem('specialtyAbility', item, index, item.specialtyName)"
                    >
                      <i class="t_delete-icon"></i>
                    </div>
                  </div>
                </div>
                <!-- <SpecialtyAbility
                  v-show="specialtyAbilityFlag"
                  ref="specialtyAbility"
                /> -->
              </section>
              <!-- 证书 -->
              <section class="block pt30">
                <div class="title">
                  证书
                  <div
                    class="add-btn"
                    @click="addItem('certificates')"
                    v-if="!certificatesFlag && certificates.length > 0"
                  >
                    + 添加证书
                  </div>
                </div>
                <div
                  class="empty-btn"
                  @click="addItem('certificates')"
                  v-if="certificates.length <= 0 && !certificatesFlag"
                >
                  <div class="t_add_box">
                    <div> <i class="add-icon"></i>添加证书</div>
                  </div>
                </div>
                <div class="word-record-item" v-if="!certificatesFlag">
                  <div class="educate" v-for="(item, index) in certificates">
                    {{ item.certificatesName
                    }}<span class="info info_left">{{ item.time }}</span>
                    <!-- <div
                      class="edit-btn"
                      type="text"
                      @click="editItem('certificates', item, index)"
                    >
                      <i class="edit-icon"></i>
                    </div> -->
                    <div
                        class="edit-btn"
                        type="text"
                        @click="deleteItem('certificates', item, index, item.certificatesName)"
                      >
                        <i class="t_delete-icon"></i>
                      </div>
                  </div>
                </div>
                <!-- <Certificates v-show="certificatesFlag" ref="certificates" /> -->
              </section>
              <!-- 已修课程 -->
              <section class="block pt30">
                <div class="title">
                  已修课程
                  <div
                    class="add-btn"
                    @click="addItem('courses')"
                    v-if="!coursesFlag && courses.length > 0"
                  >
                    + 添加课程
                  </div>
                </div>
                <div
                  class="empty-btn"
                  @click="addItem('courses')"
                  v-if="courses.length <= 0 && !coursesFlag"
                >
                  <div class="t_add_box">
                    <div> <i class="add-icon"></i>添加已修课程 </div>
                  </div>

                </div>
                <div class="word-record-item" v-if="!coursesFlag">
                  <div class="educate" v-for="(item, index) in courses">
                    {{ item.coursesName }}<span class="info info_left">{{ item.time }}</span>
                    <div
                      class="edit-btn"
                      type="text"
                      @click="deleteItem('courses', item, index, item.coursesName)"
                    >
                      <i class="t_delete-icon"></i>
                    </div>
                  </div>
                </div>
                <!-- <Courses v-show="coursesFlag" ref="courses" /> -->
              </section>
              <!-- 社会实践/活动经历 -->
              <section class="block pt30">
                <div class="title">
                  社会实践/活动经历
                  <div
                    class="add-btn"
                    @click="addItem('practiceExperience')"
                    v-if="!practiceExperienceFlag && practiceExperience.length > 0"
                  >
                    + 添加社会实践/活动经历
                  </div>
                </div>
                <div
                  class="empty-btn"
                  @click="addItem('practiceExperience')"
                  v-if="practiceExperience.length <= 0 && !practiceExperienceFlag"
                >
                <div class="t_add_box">
                  <div> <i class="add-icon"></i>添加社会实践/活动经历 </div>
                </div>
                </div>
                <div
                  class="job-wish-item"
                  v-for="(item, index) in practiceExperience"
                  :key="index"
                  v-if="!practiceExperienceFlag"
                >
                  <div class="row1">{{ item.practiceName }}</div>
                  <div class="row4">
                    <span class="value">{{ item.beginTime }}~{{ item.endTime }}</span>
                  </div>
                  <div
                    class="row4"
                    v-if="item.practiceDescription"
                    v-html="item.practiceDescription.replace(/\n/gm, '<br>')"
                  ></div>
                  <div
                    class="edit-btn top0"
                    type="text"
                    @click="editItem('practiceExperience', item, index)"
                  >
                    <i class="edit-icon"></i>
                  </div>
                  <div
                      class="t_delete-btn"
                      type="text"
                      @click="deleteItem('practiceExperience', item, index, item.practiceName)">
                      <i class="t_delete-icon"></i>
                    </div>
                </div>
                <!-- <PracticeExperience
                  v-show="practiceExperienceFlag"
                  ref="practiceExperience"
                /> -->
              </section>
            </el-form>
            <div class="btnRow">
              <!-- <div class="btns" @click="openReivew">预览简历</div> -->
              <div class="btns" @click="submitFun(false)">保存简历</div>
            </div>
          </section>
          <el-drawer
            title="简历预览"
            size="80%"
            :visible.sync="drawerDialog"
            direction="rtl"
            style="z-index: 99999"
            :append-to-body="true"
          >
            <ResumeReview :hideEdit="true" ref="ResumeReview" />
          </el-drawer>
        </div>
    </div>
</template>
<script>
import PageCom from "@/components/page/index.vue";
import { mapActions, mapState, mapMutations } from "vuex";
import { educationOptions } from "@/utils/frontDataDict.js";
import { getAge } from "../../utils/utils";
import {
  createStudentCurriculumVitae,
  updateStudentCurriculumVitae,
  getStudentCurriculumVitae,
  getStudentCurriculumVitaeBylogin,
  upUserInfo,
} from "../../request/api";
// import InternshipDesire from "./components/internshipDesire.vue";
// import EducationalExperience from "./components/educationalExperience.vue";
// import WorkExperience from "./components/workExperience.vue";
// import ProjectExperience from "./components/projectExperience.vue";
// import LanguageAbility from "./components/languageAbility.vue";
// import SpecialtyAbility from "./components/specialtyAbility.vue";
// import Certificates from "./components/certificates.vue";
// import Courses from "./components/courses.vue";
// import PracticeExperience from "./components/practiceExperience.vue";
import ResumeReview from "./components/resumeReview.vue";
// import SelectCom from "./components/selectCom.vue";
import { Dialog } from 'vant';
export default {
  // 组件名称
  name: "demo",
  // 组件参数 接收来自父组件的数据
  props: {},

  // 局部注册的组件
  components: {
    ResumeReview,
  },
  // 组件状态值
  data() {
    return {
      drawerDialog: false,
      userInfo: {},
      jobStatusFrom: {
        jobStatus: null,
        inJobTime: null,
      },
      jobStatusFlag: false,
      internshipDesireFlag: false,
      educationalExperienceFlag: false,
      workExperienceFlag: false,
      projectExperienceFlag: false,
      languageAbilityFlag: false,
      specialtyAbilityFlag: false,
      certificatesFlag: false,
      coursesFlag: false,
      practiceExperienceFlag: false,
      name: "", //简历名称
      internshipDesire: [], //实习意向
      educationalExperience: [], //教育经历列表
      workExperience: [], //工作、实习经历列表
      projectExperience: [], //项目经历列表
      languageAbility: [], //语言能力列表
      specialtyAbility: [], //专业技能列表
      certificates: [], //证书列表
      courses: [], //已修课程列表
      practiceExperience: [], //实践经验
    };
  },
  computed: {
    ...mapState(["USER_INFO", "curriculumId"]),
  },
  watch: {
    USER_INFO: function (newValue, oldValue) {
      newValue.birthday && (newValue.age = getAge(newValue.birthday) + "岁");
      let { jobStatus, inJobTime } = newValue;
      // this.jobStatusFrom.jobStatus = jobStatus
      // this.jobStatusFrom.inJobTime = inJobTime
      this.userInfo = newValue;
    },
    "$route": {
      handler(to, from) {
        //  console.log(this.internshipDesire)
        // console.log(this)
        // let formItem = sessionStorage.getItem("formItem")
        // console.log(formItem, 'formItem')

        // if(!formItem) return
        // let itemFormData = JSON.parse(formItem)
        // console.log(itemFormData, 'itemFormDataitemFormData')
        // // if (itemFormData) {
        // setTimeout(() => {
        //   if (itemFormData.index != null) {
        //     this.$set(this[itemFormData.objName], itemFormData.index, itemFormData)
        //        console.log(this[itemFormData.objName], 'this[itemFormData.objName]')
        //   } else {
        //       this[itemFormData.objName].push(itemFormData)
        //     }
        //   this[itemFormData.objName][itemFormData.index] = itemFormData
        //   console.log(this.internshipDesire)
        //   sessionStorage.removeItem("formItem")
        //   }, 500)
        // }
        console.log(this.internshipDesire)

      },
      deep: true,
      immediate: true
    }
  },
  activated() {
    console.log('mobile-activated')
    this.setItemObj()
    
  },
  beforeDestroy() {
    
  },
  // 组件方法
  methods: {
    setItemObj() {
      let formItem = sessionStorage.getItem("formItem")
      console.log(formItem, 'formItem')

      if (!formItem) return this.init();
      let itemFormData = JSON.parse(formItem)
      console.log(itemFormData, 'itemFormDataitemFormData')
      // if (itemFormData) {
      setTimeout(() => {
        if (itemFormData.objName == 'userInfo') {
          this.userInfo = itemFormData
          sessionStorage.removeItem("formItem")
          return
        }
        if (itemFormData.index != null) { 
          this.$set(this[itemFormData.objName], itemFormData.index, itemFormData)
          console.log(this[itemFormData.objName], 'this[itemFormData.objName]')
        } else {
          this[itemFormData.objName].push(itemFormData)
        }
        this[itemFormData.objName][itemFormData.index] = itemFormData
        console.log(this.internshipDesire)
        sessionStorage.removeItem("formItem")
      }, 500)
    },
    ...mapActions(["FETCH_USER_INFO"]),
    ...mapMutations(["setCurriculumId"]),
    // 通过抽屉查看简历预览
    openReivew() {
      let data = this.submitFun(true);
      if (!data) return;
      this.drawerDialog = true;
      setTimeout(() => {
        this.$refs.ResumeReview.open(data);
      });
    },
    
    openJobStatusEdit() {
      let userInfo = this.userInfo
      this.$router.push({
        name: 'editItem',
        query: {
          objName: 'userInfo',
          data: JSON.stringify({
            userInfo
          }),
        }
      })
      
      // this.jobStatusFlag = true;
    },
    submitJobStatus() {
      if (!this.jobStatusFrom.jobStatus) {
        this.$message.error("请选择当前状态");
        return;
      }
      if (!this.jobStatusFrom.inJobTime) {
        this.$message.error("请选择入职时间");
        return;
      }
      this.userInfo.jobStatus = this.jobStatusFrom.jobStatus;
      this.userInfo.inJobTime = this.jobStatusFrom.inJobTime;
      upUserInfo(this.userInfo).then((res) => {
        if (res.code === 0 && res.data) {
          console.log(this.userInfo);
          this.jobStatusFlag = false;
        } else {
          this.$message.error(res.msg);
        }
      });
    },
    fetchJSON(str, key) {
      if (!str) return [];
      let arr = JSON.parse(str);
      if (arr.length <= 0) return [];
      this[key] = arr;
    },
    getEducationOptions(id) {
      let val = "";
      educationOptions.forEach((e) => {
        if (!e.children) return;
        let list = e.children.filter((v) => v.value == id);
        list.length > 0 && (val = list[0].label);
      });
      return val;
    },
    init() {
      let { id, index = 0 } = this.$route.query;
      if (!id) {
        this.name = `模板${index + 1}`;
        return;
      }
      getStudentCurriculumVitae({
        id,
      }).then((res) => {
        if (res.data) {
          console.log(res.data, '得到内容')
          this.fetchJSON(res.data.internshipDesire, "internshipDesire");
          res.data.educationalExperience.forEach((v) => {
            if (v.id) {
              delete v.id;
            }
          });
          this.name = res.data.name;
          this.educationalExperience = res.data.educationalExperience;
          this.fetchJSON(res.data.workExperience, "workExperience");
          this.fetchJSON(res.data.projectExperience, "projectExperience");
          this.fetchJSON(res.data.languageAbility, "languageAbility");
          this.fetchJSON(res.data.specialtyAbility, "specialtyAbility");
          this.fetchJSON(res.data.certificates, "certificates");
          this.fetchJSON(res.data.courses, "courses");
          this.fetchJSON(res.data.practiceExperience, "practiceExperience");
        } else {
        }
      });
    },
    linkTo(routeName) {
      this.$router.push({ name: routeName });
    },
    // 删除确认
    deleteConfirm(data) {
      console.log("删除确认>>>>", data);
    },
    // 城市切换
    handleCityChange(data) {
      console.log("期望城市>>>>", data);
    },
    handleOpen(dialogName) {
      this[dialogName] = true;
    },
    // 所属行业切换
    businessAreaChange(data) {
      console.log("data>>>>", data);
    },
    // 点击模块编辑，切换状态
    editModule(key) {
      this[key] = true;
    },
    editJobStatus() {
      this.jobStatusFlag = !this.jobStatusFlag;
    },
   
    // 跳转编辑
    gotoItemEdit(key, item, index) {
      console.log('跳转带参', key, item, index)
      this.$router.push({
        name: 'editItem',
        query: {
          objName: key,
          data: JSON.stringify(item),
          index
        }
      })
    },
     editItem(key, item = {}, index = null) {
      console.log(key, item, index)
      this.gotoItemEdit(key, { ...item, isAdd: "edit" }, index)
      
    },
    deleteItem(key, item = {}, index = null, deleteName) {
      console.log(item)
      Dialog.confirm({
        title: '删除提示',
        message: `您确定要删除" ${deleteName} "这条内容吗?`,
        confirmButtonColor: '#3D6CB0'
      })
        .then(() => {
        this[key].splice(index, 1)

          // on confirm
        })
        .catch(() => {
          // on cancel
        });
    },
    addItem(key, item = {},index =null) {
      this.gotoItemEdit(key, { ...item, isAdd:"add" }, index)
    },
    editFun(key, item = {}, index = null) {
      this[`${key}Flag`] = true;
      if (JSON.stringify(index) != "null") {
        this.$refs[key].init(item, index);
      }
    },
    closeFun(key) {
      this[`${key}Flag`] = false;
    },
    deleteFun(key, index) {
      this[key].splice(index, 1);
    },
    upDate(key, data, index = null) {
      JSON.stringify(index) != "null"
        ? (this[key][index] = data)
        : this[key].push(data);
    },
    /**
     * 提交数据 / 预览数据
     * @param {Boolean} review 是否为预览模式 true 拿到预览的数据 fasle 提交
     */
    submitFun(review = false) {
      let {
        internshipDesire, //实习意向
        educationalExperience, //教育经历列表
        workExperience, //工作、实习经历列表
        projectExperience, //项目经历列表
        languageAbility, //语言能力列表
        specialtyAbility, //专业技能列表
        certificates, //证书列表
        courses, //已修课程列表
        practiceExperience, //实践经验
        name,
      } = this;
      if (!name) {
        this.$message.error("请填写简历名称");
        return false;
      }
      if (internshipDesire.length <= 0) {
        this.$message.error("请至少填写一项实习意向");
        return false;
      }
      if (educationalExperience.length <= 0) {
        this.$message.error("请至少填写一项教育经历");
        return false;
      }
      let {
        birthday,
        id,
        clan,
        email,
        liveCity,
        nickname,
        nativePlace,
        political,
        sex,
        studentPictureUrl,
        graduateTime,
        jobStatus,
        inJobTime,
        mobile,
      } = this.userInfo;
      let params = {
        birthday,
        clan,
        email,
        liveCity,
        nickname,
        nativePlace,
        political,
        jobStatus,
        inJobTime,
        sex,
        studentPictureUrl,
        graduateTime,
        mobile,
        studentId: id,
        name,
        studentName: nickname,
        publicStatus: "0",
        phoneNumber: mobile,
        identify: "student",
        internshipDesire: JSON.stringify(internshipDesire),
        educationalExperience: educationalExperience, //JSON.stringify(educationalExperience),
        workExperience: JSON.stringify(workExperience),
        projectExperience: JSON.stringify(projectExperience),
        languageAbility: JSON.stringify(languageAbility),
        specialtyAbility: JSON.stringify(specialtyAbility),
        certificates: JSON.stringify(certificates),
        courses: JSON.stringify(courses),
        practiceExperience: JSON.stringify(practiceExperience),
      };
      if (review) {
        return params;
      }
      if (!this.$route.query.id) {
        //没有简历id说明从没创建过简历，则走创建简历接口，否则走更新简历接口
        // setCurriculumId(666)
        createStudentCurriculumVitae(params).then((res) => {
          if (res.data) {
            //9489
            getStudentCurriculumVitaeBylogin().then((res) => {
              if (res.data) {
                this.$store.commit("setCurriculumId", res.data[0].id);
                this.$message({
                  message: "保存简历成功",
                  type: "success",
                });
                this.$router.replace({ name: "resumeReview" });
              }
            });
          } else {
            this.$message.error(res.msg);
          }
        });
      } else {
        params.id = this.$route.query.id;
        updateStudentCurriculumVitae(params).then((res) => {
          if (res.data) {
            //9489
            this.$message({
              message: "保存简历成功",
              type: "success",
            });
            this.$router.replace({ name: "resumeReview" });
          } else {
            this.$message.error(res.msg);
          }
        });
      }
    },
  },
  created() { },
  mounted() {
    this.init();
    console.log(this.internshipDesire)

  },

};
</script>

<style lang="less" scoped>
@media screen and (max-width: 480px) {
  // .showview{
  //   display: none;
  // }
  .t_showview{
    .resume-review {
    padding-bottom: 0.7rem;
      position: relative;
      width: 100%;
      background: #fff;
      // padding-bottom: 120px;
      .btnRow {
        width: 100%;
        position: fixed;
        left: 0;
        bottom: 0.1rem;
        display: flex;
        justify-content: center;
        height: 60px;
        z-index: 4;
        padding: 0 0.15rem;
        .btns {
          flex: 1;
          height: 52px;
          border-radius: 0.05rem;
          background: #3D6CB0;
          display: flex;
          justify-content: center;
          align-items: center;
          font-size: 0.18rem;
          font-family: PingFangSC-Semibold, PingFang SC;
          font-weight: 600;
          color: #ffffff;
          line-height: 0.25rem;
          cursor: pointer;
          &:first-child {
            // margin-right: 60px;
          }
        }
      }
      .block {
        position: relative;
        background: #fff;
        border-radius: 0;
        border: 0;
        border-bottom: 1px solid #f0f0f0;
        margin-bottom: 0;
        &.block:last-child{
          border: 0;
        }
      }
      .pt30 {
        padding: 20px;
        padding-bottom: 0.2rem;
      }
      .top0 {
        // top: 0 !important;
        transform: translateY(0) !important;
      }
      .mb10 {
        margin-bottom: 10px;
      }
      .contact {
        .row1 {
          display: inline-block;
          text-align: left;
          font-size: 14px;
          font-family: PingFangSC-Regular, PingFang SC;
          font-weight: 400;
          color: #37383d;
          line-height: 20px;
          margin: 12px 0;
          span {
            margin: 0;
            margin-right: 43px;
          }
        }
      }
      .user-info {
        text-align: center;
        .touxiang {
          display: block;
          width: 0.88rem;
          height: 0.88rem;
          margin: 0 auto 10px;
        }
        .row1 {
          font-size: 20px;
          font-family: PingFangSC-Semibold, PingFang SC;
          font-weight: 600;
          color: #37383d;
          line-height: 28px;
          margin-bottom: 10px;
        }
        .row2 {
          position: relative;
          display: inline-block;
          text-align: center;
          font-size: 14px;
          font-family: PingFangSC-Regular, PingFang SC;
          font-weight: 400;
          color: #9597a0;
          line-height: 20px;
          .line {
            position: relative;
            display: inline-block;
            width: 1px;
            height: 10px;
            background: #9597a0;
            margin: 0 13px;
          }
        }
      }
      .title {
        position: relative;
        font-size: 16px;
        font-family: PingFangSC-Medium, PingFang SC;
        font-weight: 500;
        color: #37383d;
        line-height: 22px;
        padding: 0;
        margin-bottom: 0.10rem;
        .isRequire {
          font-size: 14px;
          font-family: PingFangSC-Regular, PingFang SC;
          font-weight: 400;
          color: #fe4e3d;
          line-height: 20px;
          // margin-left: 12px;
        }
        .en {
          font-size: 14px;
          font-family: PingFangSC-Regular, PingFang SC;
          font-weight: 400;
          color: #9597a0;
          line-height: 20px;
          margin-left: 15px;
        }
      }
      .edit-btn {
        position: absolute;
        right: 0.12rem;
        top: 0.10rem;
        font-size: 14px;
        font-family: PingFangSC-Medium, PingFang SC;
        font-weight: 500;
        color: #2f8efe;
        line-height: 20px;
        height: 21px;
        cursor: pointer;
        .edit-icon {
          display: inline-block;
          width: 0.19rem;
          height: 0.19rem;
          background: url("../../assets/images/edit_icon.png") no-repeat center
            center / cover;
          vertical-align: middle;
        }
        .t_delete-icon {
          display: inline-block;
          width: 0.19rem;
          height: 0.19rem;
          background: url("../../assets/images/delete_icon.png") no-repeat center
            center / cover;
          vertical-align: middle;
        }
      }
      .t_delete-btn {
        position: absolute;
        right: 0.12rem;
        bottom: 0.10rem;
        font-size: 14px;
        font-family: PingFangSC-Medium, PingFang SC;
        font-weight: 500;
        color: #2f8efe;
        line-height: 20px;
        height: 21px;
        cursor: pointer;
        .t_delete-icon {
          display: inline-block;
          width: 0.19rem;
          height: 0.19rem;
          background: url("../../assets/images/delete_icon.png") no-repeat center
            center / cover;
          vertical-align: middle;
        }
      }
      .add-btn {
        position: absolute;
        right: 0;
        top: 50%;
        transform: translateY(-50%);
        font-size: 0.11rem;
        font-family: PingFangSC-Medium, PingFang SC;
        font-weight: 500;
        color: #FFFFFF;
        line-height: 0.16rempx;
        height: 27px;
        cursor: pointer;
        background: #3D6CB0;
        height: 0.22rem;
        border-radius: 0.13rem;
        padding: 0 0.1rem;
        // background: #3d6cb0;
        // border-radius: 36px;
        // color: #fff;
        // padding: 0 15px;
      }
      .empty-btn {
        cursor: pointer;
        text-align: left;
        font-size: 14px;
        font-family: PingFangSC-Medium, PingFang SC;
        font-weight: 500;
        color: #B0B0B0;
        line-height: 22px;
        text-align: center;
        .t_add_box{
          height: 48px;
          background: #F9F9F9;
          border-radius: 2px;
          border: 1px solid #F0F0F0;
          line-height: 0.48rem;
          margin-top: 0.08rem;
          font-size: 13px;
          font-family: PingFangSC-Medium, PingFang SC;
          font-weight: 500;
          color: #B0B0B0;
          // line-height: 18px;
        }
        .add-icon {
          display: inline-block;
          width: 11px;
          height: 11px;
          color: #B0B0B0;
          background: url("../../assets/images/t_add_icon.png") no-repeat center
            center / cover;
          margin-right: 0.05rem;
        }
      }
      /deep/ .delete-icon {
        position: absolute;
        right: 0;
        top: 50%;
        transform: translateY(-50%);
        cursor: pointer;
        display: inline-block;
        width: 25px;
        height: 25px;
        background: url("../../assets/images/delete_icon.png") no-repeat center
          center / cover;
      }
      /deep/ .el-button {
        width: 100px;
        height: 35px;
        line-height: 35px;
        padding: 0;
        text-align: center;
        background: #ffffff;
        border-radius: 3px;
        border: 1px solid #4677b9;
        font-size: 14px;
        font-family: PingFangSC-Semibold, PingFang SC;
        font-weight: 600;
        color: #4677b9;
      }
      /deep/ .el-button--primary {
        color: #ffffff;
      }
      ::v-deep .el-form-item__label {
        line-height: 16px;
      }
      ::v-deep .left-label {
        .cn-label {
          font-size: 20px;
          font-family: PingFangSC-Regular, PingFang SC;
          font-weight: 400;
          color: #37383d;
          line-height: 30px;
          margin-bottom: 2px;
        }
        .en-label {
          font-size: 14px;
          font-family: PingFangSC-Regular, PingFang SC;
          font-weight: 400;
          color: #9597a0;
          line-height: 20px;
        }
      }
      .job-wish-item {
        position: relative;
        background: #F9F9F9;
        padding: 0.12rem;
        border-radius: 0.02rem;
        margin-bottom: 0.2rem;
        border: 1px solid #F0F0F0;
        &.job-wish-item:last-child{
          margin-bottom: 0rem;
        }
        .row1 {
          font-size: 0.14rem;
          font-family: PingFangSC-Regular, PingFang SC;
          font-weight: 400;
          color: #37383d;
          line-height: 0.20rem;
          margin-bottom: 0.15rem;
          
          .line {
            position: relative;
            display: inline-block;
            width: 1px;
            height: 17px;
            background: #9597a0;
            margin: 0 25px;
          }
        }
        // .t_row4{
        //   font-size: 12px;
        //   font-family: PingFangSC-Regular, PingFang SC;
        //   font-weight: 400;
        //   color: #9597A0;
        //   line-height: 17px;
        // }
        .row4 {
          margin-bottom: 10px;
          font-size: 0.12rem;
          font-family: PingFangSC-Regular, PingFang SC;
          font-weight: 400;
          color: #9597A0;
          line-height: 0.17rem;
          word-break: break-all;
          display: flex;
          .row4_flex {
            // width: 40%;
            word-break: break-all;
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
            // padding-right: 10px;
          }
          .label {
            font-size: 0.12rem;
            font-family: PingFangSC-Regular, PingFang SC;
            font-weight: 400;
            color: #9597a0;
            line-height: 0.17rem;
            margin-right: 0.10rem;
          }
          .value {
            font-size: 0.12rem;
            font-family: PingFangSC-Regular, PingFang SC;
            font-weight: 400;
            color: #9597A0;;
            line-height: 0.17rem;
            margin-right: 0.30rem;
          }
        }
      }
      .word-record-item {
        position: relative;
        margin-bottom: 0.2rem;
        &.word-record-item:last-child{
          margin-bottom: 0
        }
        .educate {
          position: relative;
          font-size: 0.14rem;
          font-family: PingFangSC-Regular, PingFang SC;
          padding: 0.12rem 0.12rem 0.22rem;
          // padding-right: 100px;
          font-weight: 400;
          color: #37383d;
          line-height: 0.20rem;
          padding: 0.12rem 0.12rem 0.12rem;
          // border-bottom: 1px solid #d4d6da;
          margin-bottom: 15px;
          background: #F9F9F9;
          border-radius: 0.02rem;
          border: 0.01rem solid #F0F0F0;
          
          &:last-child {
            border-bottom: 1px solid red;
            padding-bottom: 0.12rem;
          }
          .info {
            font-size: 0.12rem;
            font-family: PingFangSC-Regular, PingFang SC;
            font-weight: 400;
            color: #9597a0;
            line-height: 0.17rem;
            // margin-left:0.12rem;
            margin-right:0.12rem;
            &.info_left{
              margin-left:0.12rem;
              color: #37383D;
            }
          }

          &:last-child {
            border-bottom: 1px solid #f9f9f9;
            margin-bottom: 0;
            // padding-bottom: 27px;
          }
          &.t_educate{
            padding-bottom: 0.30rem;
          }
        }
        .row1 {
          font-size: 0.14rem;
          font-family: PingFangSC-Regular, PingFang SC;
          font-weight: 400;
          color: #37383D;
          line-height: 0.20rem;
          margin-bottom: 0.15rem;
        }
        .row2 {
          font-size: 18px;
          font-family: PingFangSC-Medium, PingFang SC;
          font-weight: 500;
          color: #37383d;
          line-height: 33px;
          margin-bottom: 15px;
          span {
            font-size: 18px;
            font-family: PingFangSC-Medium, PingFang SC;
            font-weight: 500;
            color: #9597a0;
            line-height: 33px;
            margin-left: 218px;
          }
        }
        .row3 {
          font-size: 18px;
          font-family: PingFangSC-Regular, PingFang SC;
          font-weight: 400;
          color: #9597a0;
          line-height: 28px;
          margin-bottom: 15px;
          .line {
            position: relative;
            display: inline-block;
            width: 1px;
            height: 17px;
            background: #9597a0;
            margin: 0 25px;
          }
        }
        .row4 {
          margin-bottom: 20px;
          .label {
            font-size: 18px;
            font-family: PingFangSC-Regular, PingFang SC;
            font-weight: 400;
            color: #9597a0;
            line-height: 28px;
            margin-right: 17px;
          }
          .value {
            font-size: 18px;
            font-family: PingFangSC-Regular, PingFang SC;
            font-weight: 400;
            color: #030303;
            line-height: 28px;
            margin-right: 130px;
          }
        }
      }
    }
  }
  
}
</style>